package com.learn.english.model.param;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

import java.util.List;

/**
 * @author TISNIW
 * @version 1.0
 * @date 2025/6/14 0:08
 * @desc
 */


@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Options {

    @JsonProperty("num_keep")
    private Integer numKeep; // 保留的历史 token 数量

    @JsonProperty("seed")
    private Integer seed; // 随机种子

    @JsonProperty("num_predict")
    private Integer numPredict; // 最大预测 token 数量

    @JsonProperty("top_k")
    private Integer topK; // Top-k 采样值

    @JsonProperty("top_p")
    private Double topP; // Top-p (nucleus) 采样值

    @JsonProperty("min_p")
    private Double minP; // 最小概率阈值

    @JsonProperty("typical_p")
    private Double typicalP; // 典型采样概率

    @JsonProperty("repeat_last_n")
    private Integer repeatLastN; // 控制重复 token 的窗口大小

    @JsonProperty("temperature")
    private Double temperature; // 温度参数，控制随机性

    @JsonProperty("repeat_penalty")
    private Double repeatPenalty; // 重复 token 的惩罚系数

    @JsonProperty("presence_penalty")
    private Double presencePenalty; // 出现过的 token 惩罚系数

    @JsonProperty("frequency_penalty")
    private Double frequencyPenalty; // 频率惩罚系数

    @JsonProperty("penalize_newline")
    private Boolean penalizeNewline; // 是否对换行符进行惩罚

    @JsonProperty("stop")
    private List<String> stop; // 停止词列表

    @JsonProperty("numa")
    private Boolean numa; // 是否启用 NUMA 支持

    @JsonProperty("num_ctx")
    private Integer numCtx; // 上下文长度（token 数量）

    @JsonProperty("num_batch")
    private Integer numBatch; // 批处理 token 数量

    @JsonProperty("num_gpu")
    private Integer numGpu; // 使用的 GPU 数量

    @JsonProperty("main_gpu")
    private Integer mainGpu; // 主 GPU ID

    @JsonProperty("use_mmap")
    private Boolean useMmap; // 是否使用内存映射文件加载模型

    @JsonProperty("num_thread")
    private Integer numThread; // 线程数

    @Override
    public String toString() {
        return "{\n" +
                "\tnum_keep: " + numKeep + ",\n" +
                "\tseed: " + seed + ",\n" +
                "\tnum_predict: " + numPredict + ",\n" +
                "\ttop_k: " + topK + ",\n" +
                "\ttop_p: " + topP + ",\n" +
                "\tmin_p: " + minP + ",\n" +
                "\ttypical_p: " + typicalP + ",\n" +
                "\trepeat_last_n: " + repeatLastN + ",\n" +
                "\ttemperature: " + temperature + ",\n" +
                "\trepeat_penalty: " + repeatPenalty + ",\n" +
                "\tpresence_penalty: " + presencePenalty + ",\n" +
                "\tfrequency_penalty: " + frequencyPenalty + ",\n" +
                "\tpenalize_newline: " + penalizeNewline + ",\n" +
                "\tstop: " + stop + ",\n" +
                "\tnuma: " + numa + ",\n" +
                "\tnum_ctx: " + numCtx + ",\n" +
                "\tnum_batch: " + numBatch + ",\n" +
                "\tnum_gpu: " + numGpu + ",\n" +
                "\tmain_gpu: " + mainGpu + ",\n" +
                "\tuse_mmap: " + useMmap + ",\n" +
                "\tnum_thread: " + numThread + "\n" +
                "}";
    }
}
